Thread: map with char[30] as key

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    269

    map with char[30] as key

    Hi, I'm trying to just create a map of with char[30] as the key, and type test as the value.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <map>
    #include <string.h>
    
    int main()
    {
      struct test
      {
        int number;
        char name[30];
      };
      typedef struct test test;
    
      std::map <char[30], test*> buckets;
      return 0;
    }
    However, when compiling, I get the error:

    Code:
    stupid.c: In function ‘int main()’:
    stupid.c:23: error: template argument for ‘template<class _T1, class _T2> struct std::pair’ uses local type ‘main()::test’
    stupid.c:23: error:   trying to instantiate ‘template<class _T1, class _T2> struct std::pair’
    stupid.c:23: error: template argument 4 is invalid
    stupid.c:23: error: invalid type in declaration before ‘;’ token
    What am I missing?
    Last edited by dayalsoap; 07-27-2012 at 04:10 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 07-24-2012, 10:41 AM
  2. undefined reference to `RunSwmmDll(char*, char*, char*)'
    By amkabaasha in forum C++ Programming
    Replies: 1
    Last Post: 10-31-2011, 12:33 PM
  3. Replies: 8
    Last Post: 12-08-2009, 02:47 AM
  4. Read File To Char Array with Null char init
    By MicroFiend in forum Windows Programming
    Replies: 1
    Last Post: 10-28-2003, 06:18 PM
  5. Assigning Const Char*s, Char*s, and Char[]s to wach other
    By Inquirer in forum Linux Programming
    Replies: 1
    Last Post: 04-29-2003, 10:52 PM